Skip to content

refactor: Add array generics support to converters and address some bugs#30

Merged
tymondesigns merged 5 commits into
mainfrom
refactor/class-converter
Jun 12, 2026
Merged

refactor: Add array generics support to converters and address some bugs#30
tymondesigns merged 5 commits into
mainfrom
refactor/class-converter

Conversation

@tymondesigns

Copy link
Copy Markdown
Contributor

This pull request enhances the handling of array types and promoted properties in docblock parsing and JSON Schema generation. It introduces support for extracting array element types from docblocks, improves the resolution of descriptions and default values for promoted properties, and adds an option to ignore unknown types. The changes also include utility improvements for schema type resolution and extend the test coverage to verify these behaviors.

Docblock Parsing and Array Type Extraction:

  • Extended the DocParser to extract element types from @var and @param docblock tags, including support for generic array types (e.g., array<int>, list<string>), and propagate these types into the schema via a new itemTypes property on NodeData. [1] [2] [3]

Promoted Property and Default Value Handling:

  • Improved the ClassConverter to resolve property descriptions and array element types for promoted properties using constructor @param tags, and to correctly determine default values for promoted properties. [1] [2] [3] [4]

Array Schema Generation:

  • Added logic in InteractsWithTypes to apply docblock-derived item types to array schemas, including union types, and to build the appropriate schema representation for array elements.

Type Resolution and Robustness:

  • Introduced SchemaType::tryFromScalar to safely resolve scalar types without throwing exceptions for unknown types, enabling more robust schema generation when encountering unrecognized types.

API and Test Enhancements:

  • Updated the Schema::fromClass and Schema::from methods to accept an ignoreUnknownTypes flag, allowing callers to skip properties with unknown types. Expanded test coverage in ClassConverterTest to verify new behaviors, including default value handling for promoted properties. [1] [2] [3]

Other minor changes include dependency imports and the removal of the coverage report configuration from phpunit.dist.xml.

@tymondesigns tymondesigns changed the title refactor: Add array support to class converter and address some bugs refactor: Add array generics support to converters and address some bugs Jun 12, 2026
@tymondesigns tymondesigns marked this pull request as ready for review June 12, 2026 07:55
@tymondesigns tymondesigns merged commit e195837 into main Jun 12, 2026
17 checks passed
@tymondesigns tymondesigns deleted the refactor/class-converter branch June 12, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant